//
 
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>


NS_ASSUME_NONNULL_BEGIN

@interface NT_CoreDataBase : NSObject
/**
 *  获取.xcdatamodeld文件的名称
 */
@property (nonatomic,copy,readonly) NSString *ntModelName;
/**
 *  获取.xcdatamodeld文件中创建的实体的名称
 */
@property (nonatomic,copy,readonly) NSString *ntEntityName;
/**
 *  上下文
 */
@property (nonatomic,strong) NSManagedObjectContext *ntContext;
/**
 *  数据模型对象
 */
@property (nonatomic,strong) NSManagedObjectModel *ntModel;
/**
 *  持久性存储区
 */
@property (nonatomic,strong) NSPersistentStoreCoordinator *ntPersistent;

//
- (instancetype)initWithCoreData:(NSString *)entityName modelName:(NSString *)modelName success:(void(^)(void))success fail:(void(^)(NSError *__nullable error))fail;

//
- (void)ntInsertNewEntity:(NSDictionary *)dict success:(void(^)(void))success fail:(void(^)(NSError *__nullable error))fail;

//
- (void)ntReadEntity:(NSArray *__nullable)sequenceKeys ascending:(BOOL)isAscending filterStr:(NSString *__nullable)filterStr success:(void(^)(NSArray *results))success fail:(void(^)(NSError *__nullable error))fail;


//
- (void)ntDeleteEntity:(NSManagedObject *__nullable)model key:(id __nullable)key success:(void (^)(void))success fail:(void (^)(NSError *__nullable error))fail;
//
- (void)ntUpdateEntity:(NSDictionary *)dict key:(id __nullable)key success:(void(^)(void))success fail:(void(^)(NSError *__nullable error))fail;
//全部删除
- (void)allDeleteData;

@end

NS_ASSUME_NONNULL_END
